package com.xdf.whiteaccount.utils;

/**
 * @ClassName:BusinessException
 * @Description:TODO
 * @Author:chanchaw
 * @Date:2019-12-24 8:12
 * @Version:1.0
 **/
public class BusinessException extends RuntimeException {
    private String msg;
    private JsonResult data;

    public BusinessException(String msg) {
        this.msg = msg;
    }

    public BusinessException(ResultCode rc) {
        this.data = new JsonResult(rc,null);
    }

    public BusinessException(ResultCode rc, Object data) {
        this.data = new JsonResult(rc,data);
    }

    public BusinessException(String msg, JsonResult data) {
        this.msg = msg;
        this.data = data;
    }

    private BusinessException() {
        this.msg = null;
    }

    public static BusinessException instance() {
        return new BusinessException();
    }

    public static BusinessException instance(String msg) {
        return new BusinessException(msg);
    }

    public String getMsg() {
        return msg;
    }

    public JsonResult getData() {
        return data;
    }

    @Override
    public String toString() {
        return "BusinessException{" +
                "msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
